$(function () {
    $("#loginBtn").click(function () {
        var userName = $("#userName").val();
        var userPwd = $("#userPwd").val();
        $.ajax({
            url:"http://localhost:8082/crm/doLogin",
            type:"Get",
            data:{"userName":userName,"userPwd":userPwd},
            dataType:"JSON",
            success:function (ret) {
                console.log(ret);
                if(ret.retCode=="200"){
                    //把token写入cookie
                    setCookie("token-user",ret.token,30);
                    setCookie("userName",ret.userName,30);
                    location.href="index.html";
                }else if(ret.retCode=="300"){
                    alert("用户名密码不对,请重新输入!");
                }else{
                    alert("服务器出现异常!");
                }
            },
            error:function () {
                alert("服务连接失败!")
            }
        });
    });
});